import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_swiper_view/flutter_swiper_view.dart';
import 'package:fwanandroid/model/bean/BannerInfo.dart';

class FSwiperpagination extends SwiperPlugin {
  final List<BannerInfo> banners;

  FSwiperpagination({required this.banners});

  @override
  Widget build(BuildContext context, SwiperPluginConfig config) {
    if (banners.isEmpty) {
      return Container();
    } else {
      return Align(
        alignment: Alignment.bottomCenter,
        child: SizedBox(
          height: 30,
          child: Stack(
            children: [
              Container(
                color: Colors.black54,
              ),
              Padding(
                padding: const EdgeInsets.symmetric(horizontal: 8),
                child: Center(
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Container(
                        constraints: BoxConstraints(
                            maxWidth: MediaQuery.of(context).size.width - 50),
                        child: Text(
                          banners[config.activeIndex].title,
                          style: TextStyle(color: Colors.white),
                          overflow: TextOverflow.ellipsis,
                        ),
                      ),
                      SizedBox(
                        width: 30,
                        child: Text(
                          "${config.activeIndex + 1}/${config.itemCount}",
                          style: TextStyle(color: Colors.white),
                        ),
                      )
                    ],
                  ),
                ),
              )
            ],
          ),
        ),
      );
    }
  }
}
